<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>

<!DOCTYPE HTML>
<html lang="en-US">
	<head>
		<meta charset="UTF-8">
	    <title>登陆</title>
	    <link rel="stylesheet" href="css/bootstrap.min.css" />
		<script type="text/javascript" src="js/jquery.js"></script>
		<script type="text/javascript" src="js/bootstrap.min.js"></script>
		<style type="text/css">
			.o{
				font-size:23px;
			}
		</style>
  </head>
  
  <body>
  	
  	<%
  		String msg=(String)request.getAttribute("msg");
  	 %>
    
    	<div class="container" style="padding-top:60px">
  			<form action="login.jspx" method="post" id="form" name="form" class="container" style="width:450px">
  				
  				<div id="msg" class="alert fade in">
		            <a href="#" data-dismiss="alert" class="close">×</a>
		            <strong></strong>
		        </div>
  				
  				<span class="o">请输入用户名：</span><input type="text" id="username" class="input-xlarge" name="username">
  				<br>
			   	<span class="o">请 输 入 密 码：</span><input type="password" id="password" class="input-xlarge" name="password">
			   	<br>
			   	<input type="button" id="btn" class="pull-right btn btn-primary btn-large" value="登陆">
  			</form>
  		</div>
  		
  		<script type="text/javascript">
  			$(document).ready(function(){
  				
  				var msg="<%=msg%>";
  				$("#msg").hide();
  				
  				if(msg=="login_fail"){
	  				$("#msg").show();
	  				$("#msg").children("strong").text("用户名或密码错误");
	  			}else if(msg=="relogin"){
	  				$("#msg").show();
	  				$("#msg").children("strong").text("会话失效，请重新登陆！");
	  			}
  				
  				$("#username").blur(function(){
  					if($("#username").val()==""){
  						$("#msg").show();
  						$("#msg").children("strong").text("用户名不能为空");
  					}else{
  						$("#msg").hide();
  					}
  				});
  				
  				$("#password").blur(function(){
  					if($("#password").val()==""){
  						$("#msg").show();
  						$("#msg").children("strong").text("密码不能为空");
  					}else{
  						$("#msg").hide();
  					}
  				});
  				
  				$("#btn").click(function(){
  					if($("#password").val()!=""&&$("#username").val()!=""){
  						$("#form").submit();
  					}else{
  						$("#msg").show();
  						$("#msg").children("strong").text("账户名或密码不能为空");
  					}
  				});
  				
  			});
  		</script>
    	
  </body>
</html>
